<template>
	<view class="wanlpage-headlines flex align-center" :style="[pageData.style]" v-if="headData.length > 0">
		<image @tap="onArticleList" :src="$wanlshop.oss('/uploads/staticImage/images/default/gonggao.png')" mode="widthFix"></image>
		
		<swiper disable-touch vertical autoplay circular interval="5000" class="swiper">
			<swiper-item class="swiper-item" v-for="(item, index) in headData" :key="index">
				<view class="list text-sm">
					<view class="item text-cut" @tap="onDetails(item.id, item.title,'notice')">
						<text class="content"> {{item.title}} </text>
					</view>
				</view>
			</swiper-item>
		</swiper>
		<text @tap="onArticleList" class="wlIcon-fanhui2 margin-right-sm"></text>
	</view>
</template>
<script>
	export default {
		name: "WanlPageHeadlines",
		props: {
			pageData: {
				type: Object,
				default: function() {
					return {
						name: '头条组件',
						type: 'headlines',
						params: [],
						style: []
					}
				}
			}
		},
		data() {
			return {
				headData: []
			};
		},
		created() {
			this.loadData()
		},
		methods: {
			async loadData() {
				await uni.request({
					url: '/information/notice/index',
					success: res => {
						this.headData = res.data;
					}
				});
			},
			onArticleList(){
				this.$wanlshop.to('/pages/article/lists');
			}
		}
	}
</script>
<style>
	.wanlpage-headlines {
		display: flex;
		align-items: center;
		overflow: hidden;
	}

	.wanlpage-headlines > image{
		width: 220rpx;
		margin: 0 20rpx;
	}

	.wanlpage-headlines .swiper {
		width: 100%;
		height: 100rpx;
	}

	.wanlpage-headlines .swiper-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		position: relative;
	}
	.wanlpage-headlines .swiper-item .list{
		/* width: calc(100% - 16rpx); */
		overflow: hidden;
	}
	.wanlpage-headlines .swiper-item .list .item{
		margin: 0;
	}
	.wanlpage-headlines .swiper-item .list .item .content{
		vertical-align: middle;
		color: #444444;
		font-size: 28rpx;
	}
</style>
